"""
流量池管理相关接口
包含流量池数据查询、用户池列表、用户池历史用量等接口方法。
"""

from .api_utils import md5, get_tkey, post_api

def flow_pool_data_query(userName, passWord, poolId=None):
    """流量池数据查询接口"""
    url = "https://api.tibiot.com/api/v1/getFlowPoolNewData"
    tKey = get_tkey()
    pw = md5(md5(passWord) + tKey)
    data = {"userName": userName, "passWord": pw, "tKey": tKey}
    if poolId:
        data["poolId"] = poolId
    return post_api(url, data)

def user_pool_list_query(userName, passWord):
    """用户池列表查询接口"""
    url = "https://api.tibiot.com/api/v1/userPoolList"
    tKey = get_tkey()
    pw = md5(md5(passWord) + tKey)
    data = {"userName": userName, "passWord": pw, "tKey": tKey}
    return post_api(url, data)

def user_pool_history_usage_query(userName, passWord, poolId, month):
    """用户池历史使用数据查询接口"""
    url = "https://api.tibiot.com/api/v1/userPoolHistoryList"
    tKey = get_tkey()
    pw = md5(md5(passWord) + tKey)
    data = {"userName": userName, "passWord": pw, "tKey": tKey, "poolId": poolId, "month": month}
    return post_api(url, data)
